require("../../../utils/api.js");

var t = require("../../../utils/disapi.js"), a = getApp();

Page({
    data: {
        status: 1,
        list: "",
        page: 1,
        openid: "",
        last: 0
    },
    onLoad: function(e) {
        var o = this, i = a.globalData.openid;
        this.setData({
            openid: i
        }), wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        }), t.get_dis_money_log({
            openid: i,
            page: this.data.page,
            state: 1
        }).then(function(t) {
            if (0 == t.errno) {
                var a = t.data;
                console.log(a);
                var e = o.data.page;
                e += 1;
                var i = 0;
                a.list.length < 20 && (i = 1), o.setData({
                    list: a.list,
                    page: e,
                    last: i
                });
            }
        });
    },
    income: function(a) {
        var e = this, o = a.currentTarget.dataset.id;
        this.setData({
            status: o
        }), t.get_dis_money_log({
            openid: e.data.openid,
            page: 1,
            state: o
        }).then(function(t) {
            if (0 == t.errno) {
                var a = t.data;
                console.log(a);
                e.setData({
                    list: a.list,
                    page: 1
                });
            }
        });
    },
    onReachBottom: function(a) {
        var e = this, o = (e.data.page, e.data.status);
        t.get_dis_money_log({
            openid: e.data.openid,
            page: this.data.page,
            state: o
        }).then(function(t) {
            if (0 == t.errno) {
                var a = t.data;
                console.log(a);
                var o = e.data.list.concat(a.list), i = e.data.page + 1, s = 0;
                a.list.length < 20 && (s = 1), e.setData({
                    list: o,
                    page: i,
                    last: s
                });
            }
        });
    }
});